import LanguageMng from "../Managers/LanguageMng";
import LanguageMngTs from "../Managers/LanguageMngTs";
import LanguageType from "../Managers/LanguageType";

cc.LanguageType = cc.Enum({
    ENGLISH:1,
    HINDI:2,
    TALUGU:3,
    TAIMIL:4
});

cc.Class({
    extends: cc.Component,

    properties: {
        language:{
            default:LanguageType.ENGLISH,
            notify () {
                this._updateButtonLabel()
            },
            animatable: false
        },

        sentenceIdx:{
            default:0,
            notify () {
                this._updateButtonLabel()
            },
            animatable: false
        },
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this._updateButtonLabel(LanguageMng.language)
    },

    start () {

    },

    // update (dt) {},

    _updateButtonLabel:function (language) {
        // cc.log("读取语言：",language,"  ",language || this.language)
        LanguageMng.getSentence(language || this.language,this.sentenceIdx,function (string) {
            this.node.getComponent(cc.Label).string = string
        }.bind(this))
    }
});
